//
// File: listener.h
// Description: 
// Author: Adam Damiano
// Author: Leaf Corcoran
//

#ifndef LISTENER_H
#define LISTENER_H

#include <iostream>
#include <GL/glfw.h>
#include "guiconstants.h"
using namespace std;

class Component;

class Event {
public:
	int button; // for key event
	Event( Component* spawningComponent, int button = 0 ) : spawningComponent( spawningComponent ), button(button) { };
	Component* spawningComponent;
};

class Listener {
public:
	int type;
	virtual void mouseDown(Event e){};
	virtual void mouseUp(Event e){};

	virtual void onEnter(Event e){};
	virtual void onLeave(Event e){};
	virtual void onScroll(Event e){};
	
	virtual void mouseMove( Event e ){};
	virtual void keyDown(Event e){};
	virtual void keyUp(Event e){};
		
	virtual void onSize( Event e ){};
	virtual void actionPerformed( Event e ){}; // buttons
};

class SizeListener {
public :
	virtual void onSize( Event e ) {
		cout << "onSize " << endl;
	}
};

class MouseListener : public Listener {
public:
	virtual void mouseDown(Event e) {};
	virtual void mouseUp(Event e){};

	virtual void onEnter(Event e){};
	virtual void onLeave(Event e){};
	
	virtual void mouseMove( Event e ){};
};

class KeyListener : public Listener {
public:
	virtual void keyDown(Event e) {};
	virtual void keyUp(Event e) {};

};

class TestObserver : public MouseListener {
public:
	virtual void onEnter( Event e );
	virtual void mouseDown( Event e );
	virtual void mouseUp( Event e );
	virtual void onLeave( Event e );
	virtual void mouseMove( Event e );
	//~ virtual void keyDown( Event e ) {
		//~ cout << "Key was pressed on this. " << e.button << endl;
		//~ if ( e.button == GLFW_KEY_ENTER ) {
			//~ // this would immediately run whatever function there is, not wait for release
		//~ }
		//~ if ( e.button == GLFW_KEY_SPACE ) {
			//~ ((Button*)(e.spawningComponent))->depress();
		//~ }
	//~ }
	//~ virtual void keyUp( Event e ) {
		//~ cout << "Key was released on this. " << e.button << endl;
		//~ if ( e.button == GLFW_KEY_SPACE && ((Button*)(e.spawningComponent))->isDepressed() ) {
			//~ ((Button*)(e.spawningComponent))->raise();
		//~ }
	//~ }
};


#endif
